<?php

class Controller_Default extends Controller_Abstract
{
    function actionIndex()
    {
		return $this->_redirect(url('dashboard/show'));
    }
	function actionHealth()
	{
		exit;
	}
	function actionInfo()
	{
		phpinfo();
		exit;
	}
	function actionTest()
	{
		print_r($_SERVER);
		exit;
	}
	function actionJulyuser()
	{
		$test = new Test();
		$users = $test->getJulyUsers();
		$result = array();
		foreach ($users as $user)
		{
			$u = array();
			$u['id'] = $user['id'];
			$u['created'] = date('Y-m-d', $user['created']);
			$u['last_visit'] = date('Y-m-d', $user['last_visit']);
			$u['token'] = $test->getTokens($u['id']);
//			$u['first'] = $test->getFirstToken($u['id']);
			$u['pub'] = $user['pub'];
			$u['pla'] = $user['pla'];
			$u['gender'] = $user['gender'];
			$u['age'] = $user['age'];
			$u['zipcode'] = $user['zipcode'];
			if ($user['site_id'] == 1)
			{
				$u['game'] = 'Wheel';
			}
			else if ($user['site_id'] == 2)
			{
				$u['game'] = 'Slot';
			}
			else
			{
				$u['game'] = 'Poker';
			}
			$result[] = $u;
		}
		header( 'Content-Type: text/csv' );
		header( 'Content-Disposition: attachment;filename=july_user.csv');
		foreach ($result as $one)
		{
			echo $one['id']. ','. $one['pub']. ',' . $one['pla'] . ',' . $one['created']. ','. $one['last_visit']. ','. $one['token'] . ',' .  $one['game']. ',' .$one['gender']. ','. $one['age'] . ',' . $one['zipcode']. "\n";
		}
		exit;
	}
	function actionAug1user()
	{
		$test = new Test();
		$users = $test->getAug1Users();
		$result = array();
		foreach ($users as $user)
		{
			$u = array();
			$u['id'] = $user['id'];
			$u['created'] = date('Y-m-d', $user['created']);
			$u['last_visit'] = date('Y-m-d', $user['last_visit']);
			$u['token'] = $test->getTokens($u['id']);
//			$u['first'] = $test->getFirstToken($u['id']);
			$u['pub'] = $user['pub'];
			$u['pla'] = $user['pla'];
			$u['gender'] = $user['gender'];
			$u['age'] = $user['age'];
			$u['zipcode'] = $user['zipcode'];
			if ($user['site_id'] == 1)
			{
				$u['game'] = 'Wheel';
			}
			else if ($user['site_id'] == 2)
			{
				$u['game'] = 'Slot';
			}
			else
			{
				$u['game'] = 'Poker';
			}
			$result[] = $u;
		}
		header( 'Content-Type: text/csv' );
		header( 'Content-Disposition: attachment;filename=aug_user_1.csv');
		foreach ($result as $one)
		{
			echo $one['id']. ','. $one['pub']. ',' . $one['pla'] . ',' . $one['created']. ','. $one['last_visit']. ','. $one['token'] . ',' .  $one['game'].',' .$one['gender']. ','. $one['age'] . ',' . $one['zipcode']. "\n";
		}
		exit;
	}
	function actionAug2user()
	{
		$test = new Test();
		$users = $test->getAug2Users();
		$result = array();
		foreach ($users as $user)
		{
			$u = array();
			$u['id'] = $user['id'];
			$u['created'] = date('Y-m-d', $user['created']);
			$u['last_visit'] = date('Y-m-d', $user['last_visit']);
			$u['token'] = $test->getTokens($u['id']);
//			$u['first'] = $test->getFirstToken($u['id']);
			$u['pub'] = $user['pub'];
			$u['pla'] = $user['pla'];
			$u['gender'] = $user['gender'];
			$u['age'] = $user['age'];
			$u['zipcode'] = $user['zipcode'];
			if ($user['site_id'] == 1)
			{
				$u['game'] = 'Wheel';
			}
			else if ($user['site_id'] == 2)
			{
				$u['game'] = 'Slot';
			}
			else
			{
				$u['game'] = 'Poker';
			}
			$result[] = $u;
		}
		header( 'Content-Type: text/csv' );
		header( 'Content-Disposition: attachment;filename=aug_user_2.csv');
		foreach ($result as $one)
		{
			echo $one['id']. ','. $one['pub']. ',' . $one['pla'] . ',' . $one['created']. ','. $one['last_visit']. ','. $one['token'] . ',' .  $one['game'].',' .$one['gender']. ','. $one['age'] . ',' . $one['zipcode']. "\n";
		}
		exit;
	}
	function actionSep1user()
	{
		$test = new Test();
		$users = $test->getSep1Users();
		$result = array();
		foreach ($users as $user)
		{
			$u = array();
			$u['id'] = $user['id'];
			$u['created'] = date('Y-m-d', $user['created']);
			$u['last_visit'] = date('Y-m-d', $user['last_visit']);
			$u['token'] = $test->getTokens($u['id']);
//			$u['first'] = $test->getFirstToken($u['id']);
			$u['pub'] = $user['pub'];
			$u['pla'] = $user['pla'];
			$u['gender'] = $user['gender'];
			$u['age'] = $user['age'];
			$u['zipcode'] = $user['zipcode'];
			if ($user['site_id'] == 1)
			{
				$u['game'] = 'Wheel';
			}
			else if ($user['site_id'] == 2)
			{
				$u['game'] = 'Slot';
			}
			else
			{
				$u['game'] = 'Poker';
			}
			$result[] = $u;
		}
		ini_set('memory_limit', '512M');
		set_time_limit(600);
		header( 'Content-Type: text/csv' );
		header( 'Content-Disposition: attachment;filename=sep_user_1.csv');
		foreach ($result as $one)
		{
			echo $one['id']. ','. $one['pub']. ',' . $one['pla'] . ',' . $one['created']. ','. $one['last_visit']. ','. $one['token'] . ',' .  $one['game']. ',' .$one['gender']. ','. $one['age'] . ',' . $one['zipcode']."\n";
		}
		exit;
	}
	function actionSep2user()
	{
		$test = new Test();
		$users = $test->getSep2Users();
		$result = array();
		foreach ($users as $user)
		{
			$u = array();
			$u['id'] = $user['id'];
			$u['created'] = date('Y-m-d', $user['created']);
			$u['last_visit'] = date('Y-m-d', $user['last_visit']);
			$u['token'] = $test->getTokens($u['id']);
//			$u['first'] = $test->getFirstToken($u['id']);
			$u['pub'] = $user['pub'];
			$u['pla'] = $user['pla'];
			$u['gender'] = $user['gender'];
			$u['age'] = $user['age'];
			$u['zipcode'] = $user['zipcode'];
			if ($user['site_id'] == 1)
			{
				$u['game'] = 'Wheel';
			}
			else if ($user['site_id'] == 2)
			{
				$u['game'] = 'Slot';
			}
			else
			{
				$u['game'] = 'Poker';
			}
			$result[] = $u;
		}
		ini_set('memory_limit', '512M');
		set_time_limit(600);
		header( 'Content-Type: text/csv' );
		header( 'Content-Disposition: attachment;filename=sep_user_2.csv');
		foreach ($result as $one)
		{
			echo $one['id']. ','. $one['pub']. ',' . $one['pla'] . ',' . $one['created']. ','. $one['last_visit']. ','. $one['token'] . ',' .  $one['game'].',' .$one['gender']. ','. $one['age'] . ',' . $one['zipcode']. "\n";
		}
		exit;
	}
}

?>